/**
 * Created by zeopean on 2015/9/23.
 */
$(function(){
    /** 初始化ajax */
    jQuery.ajaxSetup({
        case:false,
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });

    /** 保存操作 */
    $('.save_org').bind('click' , function(){
        $.ajax({
            type:"post",
            url:EditInvestOrg,
            dataType:"json",
            data:$('#form_org').serialize(),
            success:function(obj){
                if(obj.level === "success"){
                    noty({text:obj.message,type:obj.level,timeout:1000});
                }
            },
            error:function(obj){
                var datajson = obj.responseJSON;
                noty({text:datajson.message,type:datajson.level,timeout:2000});
            }
        });
    });
    /** end */

    /** 删除 投资机构 */
    $('.del').bind('click' , function(){
        var orgId  =   $(this).attr('data');
        var tmp     =   $(this);
        $.ajax({
            type: "get",
            url: DelInvestOrgById,
            dataType: "json",
            data: {
                'orgId'    : orgId
            },
            success: function (obj) {
                if (obj.level === "success") {
                    noty({text:obj.message,type:obj.level,timeout:500});
                    tmp.parents('tr').hide();
                }
            },
            error: function (obj){
                var datajson = obj.responseJSON;
                noty({text:datajson.message,type:datajson.level,timeout:1000});
            }
        });
    });
    /** end */

});

